var cluster = require('cluster');
var http = require('http');
var numCPU = require('os').cpus().length;

if(cluster.isMaster){
    for(var i = 0 ; i < numCPU ; i++){
        cluster.fork();
    }

    cluster.on('death', function(worker){
        console.log('worker '+ worker.pid + " died!" );
        cluster.fork();
    });
}else{
    http.createServer(function(req, res){
        res.writeHead(200 , {"content-type":"text/html"});
        res.end("Hello,Cluster! ");
    }).listen(8888);
}
